import random


def bubble_sort(alist):
    for j in range(len(alist)):
        exchage = False
        for i in range(0, len(alist) - 1 - j):
            if alist[i] > alist[i + 1]:
                alist[i], alist[i + 1] = alist[i + 1], alist[i]
                exchage = True
        print(li)
        if not exchage:
            return
    return alist


li = [6, 7, 8, 9, 1, 2, 3, 4, 5]
# li = [random.randint(1, 100) for i in range(5)]
print(li)
res = bubble_sort(li)
print(res)
